﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using Yang.DataBase;

public partial class WebServices_deleteRecord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/plain";
        Response.Charset = "utf-8";
        string strJson = "";

        string ProductType = "";                //成果类型
        int pageIndex = 1;
        int rowsIndex = 1;

        ProductType = Request.QueryString[0].ToString();
        rowsIndex = Int32.Parse(Request.QueryString[1].ToString());
        pageIndex = Int32.Parse(Request.QueryString[2].ToString());

        ProductType = Utility.ProductId2Name(ProductType);
        try
        {
            string strSQL = "select 编号 from " + ProductType + " Order by 编号";
            DataSet ds = Database.Query(strSQL);

            int id = 0;

            if (ds.Tables[0].Rows.Count > 0)
            {
                id = Int32.Parse(ds.Tables[0].Rows[(pageIndex - 1) * 10 + rowsIndex][0].ToString());
            }

            strSQL = "DELETE FROM " + ProductType + "  WHERE 编号 = " + id;

            Database.ExecuteSql(strSQL);

            strJson = "{\"result\":\"OK\"}";
        }
        catch(Exception ex)
        {
            Log.WriteException(DateTime.Now.ToString() + ";" + ex.Message);
            strJson = "{\"result\":\"ERROR\"}";

        }
        Response.Write(strJson);

    }


}

